package www.openteam.com.model.qualityCntrl;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import www.openteam.com.base.BaseModel;
import www.openteam.com.bean.IPQCBadReason;
import www.openteam.com.bean.IPQCCheckItem;
import www.openteam.com.bean.IPQCCheckMan;
import www.openteam.com.bean.IPQCDispose;
import www.openteam.com.bean.IPQCProduce;


/**
 * Created by Administrator on 2018/1/29 0029.
 */

public class IPQC00Model extends BaseModel {

    public void findCheckItem( final IPQC00Model.CheckItemListener listener){
        httpApiService.findCheckItem().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<IPQCCheckItem>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        listener.fail(e);
                    }

                    @Override
                    public void onNext(IPQCCheckItem ipqcCheckItem) {
                        listener.success(ipqcCheckItem);
                    }
                });
    }

    public void findBadReason( final IPQC00Model.BadReasonListener listener){
        httpApiService.findBadReason().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<IPQCBadReason>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        listener.fail(e);
                    }

                    @Override
                    public void onNext(IPQCBadReason ipqcBadReason) {
                        listener.success(ipqcBadReason);
                    }
                });
    }

    public void findDispose( final IPQC00Model.DisposeListener listener){
        httpApiService.findDispose().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<IPQCDispose>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        listener.fail(e);
                    }

                    @Override
                    public void onNext(IPQCDispose ipqcDispose) {
                        listener.success(ipqcDispose);
                    }
                });
    }

    public interface CheckItemListener{

        void success(IPQCCheckItem ipqcCheckItem);

        void fail(Throwable e);
    }

    public interface BadReasonListener{

        void success(IPQCBadReason ipqcBadReason);

        void fail(Throwable e);
    }

    public interface DisposeListener{

        void success(IPQCDispose ipqcDispose);

        void fail(Throwable e);
    }
}
